home *** CD-ROM | disk | FTP | other *** search
- ;/* Execute me to compile with DICE V3.0
- dcc PopupCycle.c -mi -ms -proto -lbgui -lpopupmenuclass.o
- quit
- */
- /*
- ** $RCSfile: PopupCycle.c,v $
- ** Description: Simple BGUI external class demonstration.
- ** Copyright: (C) Copyright 1994 Paul Weterings.
- ** All Rights Reserved.
- **
- ** $Author: Paul Weterings $
- ** $Revision: 1.2 $
- ** $Date: 1994/08/03 11:38:53 $
- */
-
- #include <exec/types.h>
- #include <exec/libraries.h>
- #include <dos/dos.h>
- #include <libraries/bgui.h>
- #include <libraries/bgui_macros.h>
-
- #include <clib/macros.h>
- #include <clib/alib_protos.h>
-
- #include <proto/exec.h>
- #include <proto/intuition.h>
- #include <proto/bgui.h>
-
- #include <stdio.h>
- #include <stdlib.h>
- #include <stdlib.h>
- #include <math.h>
-
- /*
- ** Keep in mind that you need Markus Aalto's PopUpMenu Class
- ** his archive is called 'pppmnc11.lha'
- **
- ** Note from Jan to DICE users:
- ** Since the DICE linker DLink does not seem to know how to
- ** handle HUNK_LIB hunks like in the .lib file supplied with the
- ** PopupMenuClass you will have to link with the supplied
- ** popupmenuclass.o file. This file is compiled without registered
- ** args (-mRR).
- */
-
- #include <BoopsiObjects/PopUpMenuClass.h>
-
- /*
- ** Library base pointers.
- */
- struct Library *BGUIBase = NULL;
-
- /*
- ** Object ID's
- */
- #define ID_QUIT 1
- #define ID_POPUP 2
-
- /*
- ** Version checking
- */
- extern struct Library *SysBase;
-
- Class *PopUpMenuClass;
- struct DrawInfo *dri;
- UBYTE *names[] = {
- "Paul Weterings",
- "supplied this",
- "little class demo",
- "Thanks to",
- "Markus Aalto",
- "for the",
- "freely",
- "Distributable",
- "PopUpMenu class",
- "Markus: s37732v@vipunen.hut.fi",
- "Paul : Paul@grafix.wlink.nl",
- NULL
- };
-
-
- int main( int argc, char *argv[] )
- {
- Object *WN_Window, *GA_Quit, *GA_Master, *GA_Popup;
- struct Window *win;
- struct Screen *scr;
- ULONG winsig = 0L, sigrec, rc;
- BOOL running = TRUE;
-
- /*
- ** Needed for the class
- */
- struct Node *node;
- struct List labels;
- UBYTE **strings = names;
- UWORD Height;
-
-
- /*
- ** Need al least OS 2.0.
- */
- if ( SysBase->lib_Version < 37 ) {
- puts( "> OS 2.0 required!" );
- exit( 0 );
- }
-
- /*
- ** Open the libraries.
- */
- if ( BGUIBase = OpenLibrary( BGUINAME, BGUIVERSION ))
- {
- if ( scr = LockPubScreen( NULL ))
- {
- /*
- ** Create the PopUpMenu class
- */
- if (PopUpMenuClass = CreatePopUpMenuClass())
- {
-
- /*
- ** Create the list with items
- */
- NewList( &labels );
- while( *strings )
- {
- node = (struct Node *)AllocVec( sizeof(struct Node), MEMF_ANY|MEMF_CLEAR );
- if( node )
- {
- node->ln_Name = *strings;
- AddTail( &labels, node );
- }
- else
- {
- puts( "Not enough memory for nodes in List" );
- goto nolist;
- }
- strings++;
- }
-
- /*
- ** I guess this variable can be filled better by BGUI
- */
- if( dri = GetScreenDrawInfo( scr ) )
- Height = MAX(dri->dri_Font->tf_YSize + INTERHEIGHT, PUMG_MinHeight );
- else
- goto noscrdrwinf;
- /*
- ** Create a small window.
- */
- WN_Window = WindowObject,
- WINDOW_Title, "PopUpCycle",
- WINDOW_Screen, scr,
- WINDOW_SmartRefresh, TRUE,
- WINDOW_MasterGroup,
- GA_Master = VGroupObject, HOffset( 4 ), VOffset( 4 ), Spacing( 4 ),
- StartMember,
- GA_Popup = ExternalObject,
- EXT_MinWidth, 130,
- EXT_MinHeight, Height+2,
- EXT_Class, PopUpMenuClass,
- EXT_TrackAttr, PUMG_Active,
- PUMG_Labels, &labels,
- PUMG_TextFont, dri->dri_Font, /* Not really needed */
- PUMG_NewLook, TRUE, /* Play with this! */
- GA_RelVerify, TRUE,
- GA_ID, ID_POPUP,
- EndObject,
- FixMinHeight,
- EndMember,
- StartMember,
- GA_Quit = KeyButton( "_Quit", ID_QUIT ), FixMinHeight,
- EndMember,
- EndObject, /* VGroupObject */
- EndObject; /* WindowObject */
-
- if ( WN_Window ) {
- /*
- ** Make button selectable by the keyboard.
- */
- GadgetKey( WN_Window, GA_Quit, "q" );
- /*
- ** Open up the window.
- */
- if ( win = WindowOpen( WN_Window )) {
- /*
- ** Obtain window sigmask.
- */
- GetAttr( WINDOW_SigMask, WN_Window, &winsig );
- /*
- ** Wait for messages.
- */
- do {
- sigrec = Wait( winsig );
-
- /*
- ** Window signal?
- */
- if ( sigrec & winsig ) {
- while ( WN_Window && (( rc = HandleEvent( WN_Window )) != WMHI_NOMORE )) {
- switch ( rc ) {
-
- case WMHI_CLOSEWINDOW:
- case ID_QUIT:
- /*
- ** The end.
- */
- running = FALSE;
- break;
- }
- }
- }
- }
- while ( running );
- }
- DisposeObject( WN_Window );
- }
- noscrdrwinf:
- DisposePopUpMenuClass( PopUpMenuClass );
-
- while( node = RemHead( &labels ) )
- FreeVec( (void *)node );
- nolist:
- FreeScreenDrawInfo( scr, dri );
- }
- UnlockPubScreen( NULL, scr );
- }
- CloseLibrary( BGUIBase );
- }
- }
-
- #ifdef _DCC
- int wbmain( struct wbStartup *wbs )
- {
- return( main( 0, NULL ));
- }
- #endif
-